﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Protocol
{
    public class ReqCreateUser
    {
        public string UserName;

        public byte[] Encode()
        {
            byte[] buffer;
            using (MemoryStreamExt ms = new MemoryStreamExt())
            {
                ms.WriteUTF8String(UserName);
                buffer = new byte[ms.Length];
                buffer = ms.GetBuffer();
            }
            return buffer;
        }

        public static ReqCreateUser Decode(byte[] buffer)
        {
            ReqCreateUser dto = new ReqCreateUser();
            using (MemoryStreamExt ms = new MemoryStreamExt(buffer))
            {
                dto.UserName = ms.ReadUTF8String();
            }
            return dto;
        }
    }
}
